package com.ecommerce.order.client;

import com.ecommerce.order.dto.ProductResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 产品服务Feign客户端
 */
@FeignClient(name = "product-service", path = "/products")
public interface ProductServiceClient {

    /**
     * 获取产品详情
     * @param productId 产品ID
     * @return 产品响应
     */
    @GetMapping("/{productId}")
    ProductResponse getProductById(@PathVariable("productId") Long productId);

    /**
     * 减少库存
     * @param productId 产品ID
     * @param quantity 数量
     */
    @PostMapping("/{productId}/reduce-stock")
    void reduceStock(@PathVariable("productId") Long productId, @RequestParam("quantity") Integer quantity);
}